package com.baidu.lib_home.fragment

import android.os.Bundle
import androidx.fragment.app.activityViewModels
import androidx.recyclerview.widget.LinearLayoutManager
import com.baidu.lib_common.base.BaseFragment
import com.baidu.lib_home.adapter.MusicAdapter
import com.baidu.lib_home.databinding.FragmentMusicListBinding
import com.baidu.lib_home.viewmodel.MainViewModel

class MusicListFragment: BaseFragment<FragmentMusicListBinding>(){
    val mainViewModel: MainViewModel by activityViewModels()
    override fun initUI(savedInstanceState: Bundle?) {
        super.initUI(savedInstanceState)
        val adapter = MusicAdapter()
        mBinding.recyclerView.adapter = adapter
        mBinding.recyclerView.layoutManager = LinearLayoutManager(requireActivity())
        mainViewModel.currentChartMusic.observe(viewLifecycleOwner){
            adapter.setNewData(it)
        }
    }
}